Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / examples / GUI examples / TwoMultiSlidersInOne.scd
blob64079fce3343dd0e38e8c7045d5bcb079879d169
1 GUI.cocoa;      // use CocoaGUI (Mac OS X native)
2 GUI.swing;      // use SwingGUI (Java based GUI)
5 //use as table
6 var size, win, data1, data2, view1, view2, swapData, data1Color, data2Color;
7 data1Color = Color.blue;
8 data2Color = Color.green;
9 size = 350 / 6;
10 data1 = {1.0.rand} ! size;
11 data2 = {1.0.rand} ! size;
13 win = Window("double multislider", Rect(200 , 450, 450, 150));
15 Button(win, Rect(0,0, 80,20)).states_([["green"],["blue"]])
16                         .action_{|v| swapData.(v.value)};
18 swapData = {|dofocusOn|
19                 view1.remove;
20                 view2.remove;
21                 if(dofocusOn == 0){
22                 view1 = MultiSliderView(win, Rect(0, 24, 350, 100))
23                                 .background_(Color.green(alpha:0.0))
24                                 .fillColor_(data1Color.alpha_(0.5))
25                                 .value_(data1)
26                                 .isFilled_(true)
27                                 .indexThumbSize_(2)
28                                 .gap_(4)
29                                 .action_({|sl| data1 = sl.value;});
30                 view2 = MultiSliderView(win, Rect(0, 24, 350, 100))
31                                 .background_(Color.green.alpha_(0.0))
32                                 .fillColor_(data2Color)
33                                 .value_(data2)
34                                 .isFilled_(true)
35                                 .indexThumbSize_(2)
36                                 .gap_(4)
37                                 .action_({|sl| data2 = sl.value;});
38                 }{
39                 view2 = MultiSliderView(win, Rect(0, 24, 350, 100))
40                                 .background_(Color.green(alpha:0.0))
41                                 .fillColor_(data2Color.alpha_(0.5))
42                                 .value_(data2)
43                                 .isFilled_(true)
44                                 .indexThumbSize_(2)
45                                 .gap_(4)
46                                 .action_({|sl| data2 = sl.value;});
47                 view1 = MultiSliderView(win, Rect(0, 24, 350, 100))
48                                 .background_(Color.green.alpha_(0.0))
49                                 .fillColor_(data1Color)                 
50                                 .value_(data1)
51                                 .isFilled_(true)
52                                 .indexThumbSize_(2)
53                                 .gap_(4)
54                                 .action_({|sl| data1 = sl.value;});
55                 }
56         
59 swapData.value(0);
60 win.front;